#include "Viewer.h"
#include "gl/glew.h"
#include "glm/fwd.hpp"
#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/quaternion.hpp>
#include "gl/freeglut.h"

#include "Loader.h"
#include "Node.h"
#include "Util.h"

std::shared_ptr<renderengine::Viewer> viewer;
void mouse(int button, int state, int x, int y) {
    viewer->mouse(button, state, x, y);
}
void motion(int x, int y) {
    viewer->motion(x, y);
}
void frame(void) {
    viewer->frame();
}
int main(int argc, char** argv)
{
    std::shared_ptr<renderengine::Loader> loader = std::make_shared<renderengine::Loader>();
    std::shared_ptr<renderengine::Node> scene =loader->load("d:/data/box.obj");
    viewer = std::make_shared<renderengine::Viewer>();
    viewer->Resize(800, 800);
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
    glutInitWindowSize(viewer->getWidth(), viewer->getHeight());
    glutCreateWindow(argv[0]);

    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutDisplayFunc(frame);
    glEnable(GL_DEPTH_TEST);
    glClearColor(0, 0, 0, 0);

    glewInit();
    viewer->commit();
    glutMainLoop();
    return 0;
}
